<?php

namespace App\Http\Controllers;

use App\Mail\LiuYanMail;
use Illuminate\Http\Request;

class LiuYanController extends Controller
{
    public function index(){
        return view('liuyan');
    }
    public function submit(Request $request){

        $this->validate($request,[
            'name'=>'required',
            'mobile'=>'required',
            'detail'=>'required'
        ],[
            'name.required'=>'请填写姓名',
            'mobile.required'=>'请填写联系方式',
            'detail.required'=>'请填写你想说的内容'
        ]);
       \Mail::to(config('mail.address'))->queue(new LiuYanMail([
           'name'=>$request->name,
           'mobile'=>$request->mobile,
           'detail'=>$request->detail,
       ]));
       return redirect()->route('liuyan.success');
    }
    public function success(){
        return view('success');
    }
}
